package ThreadingSafety;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

/**
 *  标准库里的 阻塞队列  --> (一些解释看板书, 因此先看板书, 再看IDEA.)
 */
public class TestDemo20 {
    public static void main(String[] args) throws InterruptedException {
        BlockingQueue<Integer> blockingQueue = new LinkedBlockingQueue<>(100);

        blockingQueue.put(1);
        blockingQueue.put(2);
        blockingQueue.put(3);

        System.out.println(blockingQueue.take());
        System.out.println(blockingQueue.take());
        System.out.println(blockingQueue.take());

        // 将在此阻塞
        System.out.println(blockingQueue.take());

    }
}
